module PeriphereControlP {
	provides {
		interface PeriphereControl;
	}	

	uses {
		interface Boot;
		interface GeneralIO as PositionLedPin;   // LED minta ki/be 
		interface GeneralIO as Power1Pin;   // LED minta ki/be 
		interface GeneralIO as Power2Pin;   // LED minta ki/be 
		interface GeneralIO as Power3Pin;   // LED minta ki/be 
	} 	
}

implementation {
	event void Boot.booted() {
		call PositionLedPin.makeOutput();
		call Power1Pin.makeOutput();
		call Power2Pin.makeOutput();
		call Power3Pin.makeOutput();
	}
	
	command error_t PeriphereControl.setPeripherePower(uint16_t power) {
		if (power & 1)
			call PositionLedPin.set();
		else
			call PositionLedPin.clr();

		if (power & 2)
			call Power1Pin.set();
		else
			call Power1Pin.clr();

		if (power & 4)
			call Power2Pin.set();
		else
			call Power2Pin.clr();

		if (power & 8)
			call Power3Pin.set();
		else
			call Power3Pin.clr();

		return SUCCESS;
	}

}
